home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample PMSAM / PMSAM Framework / RoboSamSlot / OutgoingLetterStream.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  8.3 KB  |  328 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OutgoingLetterStream.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Tim Harnett
  7.  
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>     1/27/95    TMH        handle unresolved recipients
  13.          <1>     1/13/95    TMH        abstract class for outgoing letter
  14.                  1/11/95    TMH        xxx put comment here xxx
  15.  
  16.     To Do:
  17. */
  18.  
  19.  
  20. #ifndef __TEXTUTILS__
  21. #include "TextUtils.h"
  22. #endif
  23.  
  24. #ifndef __PMSAMResourceIds__
  25. #include "PMSAMResourceIDs.h"
  26. #endif
  27.  
  28. #ifndef __Debug__
  29. #include "Debug.h"
  30. #endif
  31.  
  32.  
  33. #ifndef __CDSSpec__
  34. #include "CDSSpec.h"
  35. #endif
  36.  
  37. #ifndef __MSAMSlot__
  38. #include "MSAMSlot.h"
  39. #endif
  40.  
  41. #ifndef __XLetter__
  42. #include "XLetter.h"
  43. #endif
  44.  
  45. #ifndef __OutgoingLetterStream__
  46. #include "OutgoingLetterStream.h"
  47. #endif
  48.  
  49. //--------------------------------------------
  50. //    C O u t g o i n g L e t t e r S t r e a m
  51. //--------------------------------------------
  52.  
  53. #pragma segment OutgoingLetterStream
  54.  
  55. //--------------------------------------------------------------------------------
  56. COutgoingLetterStream::COutgoingLetterStream(TMSAMSlot* msamSlot)
  57. {
  58.     ASSERT(msamSlot);
  59.     fMSAMSlot = msamSlot;
  60. }
  61.  
  62.  
  63.  
  64. //--------------------------------------------------------------------------------
  65. void COutgoingLetterStream::WriteSendDate(MailTime& /* utcTime*/)
  66. {
  67.     ASSERTPRINT(false,("Must Override COutgoingLetterStream::WriteSendDate\n") );
  68. }
  69.  
  70.  
  71. //--------------------------------------------------------------------------------
  72. void COutgoingLetterStream::WriteSubject(StringPtr /*subject*/)
  73. {
  74.     ASSERTPRINT(false,("Must Override COutgoingLetterStream::WriteSubject\n") );
  75. }
  76.  
  77.  
  78. //--------------------------------------------------------------------------------
  79. void COutgoingLetterStream::BeginBody()
  80. {
  81.     
  82. }
  83.  
  84. //--------------------------------------------------------------------------------
  85. void COutgoingLetterStream::EndBody()
  86. {
  87.  
  88. }
  89.  
  90. //--------------------------------------------------------------------------------
  91. void COutgoingLetterStream::WriteBodyText(char* /*text*/,long /*textLen*/,Boolean /*more*/)
  92. {
  93.     ASSERTPRINT(false,("Must Override COutgoingLetterStream::WriteBodyText\n") );
  94. }
  95.  
  96. //--------------------------------------------------------------------------------
  97. void COutgoingLetterStream::WriteBodyStr(char* text)
  98. {
  99.     long textLen = strlen(text);
  100.     this->WriteBodyText(text,textLen,true);
  101.     
  102. }
  103.  
  104. //--------------------------------------------------------------------------------
  105. void COutgoingLetterStream::WriteBodyStr(StringPtr text)
  106. {
  107.     this->WriteBodyText((char*)&text[1],(long)text[0],true);
  108. }
  109.  
  110.  
  111.  
  112. //--------------------------------------------------------------------------------
  113. void COutgoingLetterStream::WritePict(void* /* pictData*/,long /*pictDataLen*/,Boolean /*more*/)
  114. {
  115. }
  116.  
  117.  
  118.  
  119. //--------------------------------------------------------------------------------
  120. void COutgoingLetterStream::WriteSound(void* /* soundData*/,long /*soundDataLen*/,Boolean /*more*/)
  121. {
  122. }
  123.  
  124.  
  125.  
  126. //--------------------------------------------------------------------------------
  127. void COutgoingLetterStream::WriteMovie(void* /*movieData*/,long /*movieDataLen*/,Boolean /*more*/)
  128. {
  129. }
  130.  
  131.  
  132.  
  133. //--------------------------------------------------------------------------------
  134. void COutgoingLetterStream::WriteNestedSendDate(MailTime& /* utcTime*/)
  135. {
  136.     ASSERTPRINT(false,("Must Override COutgoingLetterStream::WriteMovie\n") );
  137.  
  138. }
  139.  
  140. //--------------------------------------------------------------------------------
  141. void COutgoingLetterStream::WriteNestedSubject(StringPtr /*subject*/)
  142. {
  143.     ASSERTPRINT(false,("Must Override COutgoingLetterStream::WriteMovie\n") );
  144. }
  145.  
  146.  
  147. //--------------------------------------------------------------------------------
  148. void COutgoingLetterStream::BeginNestedLetter()
  149. {
  150.     Str255    headerStr;
  151.  
  152.     headerStr[0] = 0;
  153.     
  154.     GetIndString(headerStr, kLetterHeaderStringsResID, kNestedLetterHeader);
  155.     
  156.     this->WriteBodyStr(headerStr);
  157.     
  158. }
  159.  
  160. //--------------------------------------------------------------------------------
  161. void COutgoingLetterStream::EndNestedLetter()
  162. {
  163.     this->WriteBodyStr("\n\n");        // more assumptions.
  164. }
  165.  
  166.  
  167. //--------------------------------------------------------------------------------
  168. void COutgoingLetterStream::BeginNestedRecipients(short recipientType)
  169. {
  170.  
  171.     Str255    headerStr;
  172.  
  173.     headerStr[0] = 0;
  174.     
  175.     switch(recipientType) {
  176.     
  177.     case kMailFromBit:
  178.         GetIndString(headerStr, kLetterHeaderStringsResID, kNestedFromHeader);
  179.         break;
  180.     
  181.     case kMailToBit:
  182.         GetIndString(headerStr, kLetterHeaderStringsResID, kNestedToHeader);
  183.         break;
  184.         
  185.     case kMailCcBit:
  186.         GetIndString(headerStr, kLetterHeaderStringsResID, kNestedCcHeader);
  187.         break;
  188.                     
  189.     default:
  190.         ASSERTPRINT(false,("COutgoingLetterStream::BeginNestedRecipients Unknown recipient type =%0X\n",recipientType) );
  191.         break;
  192.     };
  193.  
  194.  
  195.     this->WriteBodyStr(headerStr);
  196.  
  197. }
  198.  
  199.  
  200.  
  201. //--------------------------------------------------------------------------------
  202. void COutgoingLetterStream::EndNestedRecipients(short /*recipientType*/)
  203. {
  204.     this->WriteBodyStr("\n\n");        // more assumptions.
  205. }
  206.  
  207.  
  208.  
  209. //--------------------------------------------------------------------------------
  210. void COutgoingLetterStream::WriteNestedRecipient(CUnpackedDSSpec& unpackedRecipient,short recipientType,short recipientCount)
  211. {
  212.  
  213.     if( fMSAMSlot->IsOurRecipient(unpackedRecipient) ) {
  214.     
  215.         this->WriteNestedRecipient(unpackedRecipient.ExtValue(),recipientType,recipientCount);
  216.  
  217.     } else {
  218.     
  219.         Str255    otherRecipient;        // non-EWorldAddress
  220.         ::MapOtherRecipient(unpackedRecipient,otherRecipient);
  221.                 
  222.         this->WriteNestedRecipient(otherRecipient,recipientType, recipientCount);
  223.  
  224.     }
  225.     
  226. }
  227.  
  228.  
  229.  
  230. //--------------------------------------------------------------------------
  231. void COutgoingLetterStream::WriteNestedRecipient(StringPtr recipient,short /*recipientType*/,short recipientCount)
  232. {
  233.  
  234.         //    Assumption : that the nested recipients are placed in the
  235.         //    outgoing letters body.  --- could be presumptious.
  236.  
  237.     if( recipientCount != 1 )
  238.         this->WriteBodyStr(",\n");
  239.         
  240.  
  241.     this->WriteBodyStr(recipient);
  242.  
  243. }
  244.  
  245.  
  246. //--------------------------------------------------------------------------------
  247. void COutgoingLetterStream::WriteResolvedRecipient(CUnpackedDSSpec& unpackedRecipient,short recipientType,short recipientCount,Boolean more)
  248. {
  249.     this->WriteResolvedRecipient(unpackedRecipient.ExtValue(),recipientType, recipientCount,more);        // we know its a string.
  250. }
  251.  
  252.  
  253. //--------------------------------------------------------------------------
  254. void COutgoingLetterStream::WriteResolvedRecipient(StringPtr /*recipient*/,short /*recipientType*/,short /*recipientCount*/,Boolean /*more*/)
  255. {
  256.     ASSERTPRINT(false,("Must Override COutgoingLetterStream::WriteResolvedRecipient \n") );
  257.  
  258. }
  259.  
  260.  
  261. //--------------------------------------------------------------------------------
  262. void COutgoingLetterStream::BeginUnResolvedRecipients(short recipientType)
  263. {
  264.  
  265.         //    We assume in the base class here that the unresolved recipient list
  266.         //    is always put into the body part of the letter. If it isn't you will have
  267.         //    override this.
  268.         
  269.         
  270.     Str255    headerStr;
  271.  
  272.     headerStr[0] = 0;
  273.     
  274.     switch(recipientType) {
  275.     
  276.     case kMailToBit:
  277.         GetIndString(headerStr, kLetterHeaderStringsResID, kUnResolvedToHeader);
  278.         break;
  279.         
  280.     case kMailCcBit:
  281.         GetIndString(headerStr, kLetterHeaderStringsResID, kUnResolvedCcHeader);
  282.         break;
  283.                     
  284.     default:
  285.         ASSERTPRINT(false,("COutgoingLetterStream::BeginUnResolvedRecipients Unknown recipient type =%0X\n",recipientType) );
  286.         break;
  287.     };
  288.  
  289.  
  290.     this->WriteBodyStr(headerStr);
  291.  
  292.  
  293. }
  294.  
  295.  
  296. //--------------------------------------------------------------------------------
  297. void COutgoingLetterStream::EndUnResolvedRecipients(short /*recipientType*/)
  298. {
  299.     this->WriteBodyStr("\n\n\n");        // more assumptions.
  300. }
  301.  
  302.  
  303.  
  304. //--------------------------------------------------------------------------------
  305. void COutgoingLetterStream::WriteUnResolvedRecipient(CUnpackedDSSpec& unpackedRecipient,short recipientType,long recipientCount)
  306. {
  307.     Str255    otherRecipient;        // un resolved Recipient
  308.     ::MapOtherRecipient(unpackedRecipient,otherRecipient);
  309.             
  310.     this->WriteUnResolvedRecipient(otherRecipient,recipientType, recipientCount);
  311.  
  312. }
  313.  
  314.  
  315. //--------------------------------------------------------------------------
  316. void COutgoingLetterStream::WriteUnResolvedRecipient(StringPtr recipient,short /*recipientType*/,long recipientCount)
  317. {
  318.         //    Assumption : that the unresolved recipients are placed in the
  319.         //    outgoing letters body.  --- could be presumptious.
  320.  
  321.     if( recipientCount != 1 )
  322.         this->WriteBodyStr(",\n");
  323.         
  324.  
  325.     this->WriteBodyStr(recipient);
  326.  
  327. }
  328.